package com.yc.testThread;

public class TestThread extends Thread {

	@Override
	public void run() {
		System.out.println("---------1-----"+ Thread.currentThread().getName());
		try {
			Thread.sleep(60000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("---------2-----"+ Thread.currentThread().getName());
	}

	public static void main(String[] args) {
		TestThread t1 = new TestThread();
		t1.setName("thread1");
		t1.start();
		ThreadGroup currentGroup = Thread.currentThread().getThreadGroup();
		int noThreads = currentGroup.activeCount();
		Thread[] lstThreads = new Thread[noThreads];
		currentGroup.enumerate(lstThreads);
		for (int i = 0; i < noThreads; i++)
			System.out.println("线程号：" + i + " = " + lstThreads[i].getName());
	}
}
